package com.designed.pattern.behavioral.strategy;


import com.designed.pattern.behavioral.strategy.core.*;

/**
 * 简单工厂 + 策略
 *
 * @author yifei
 * @description
 * @date 2024/1/2
 **/
public class CashContextEnhance {

    CashContextEnhance contextEnhance;
    private CashSuper cs;

    public CashContextEnhance(CashSuper cashSuper) {
        this.cs = cashSuper;
    }

    public CashContextEnhance(int cashType) {
        switch (cashType) {
            case 1:
                contextEnhance = new CashContextEnhance(new CashNormal());
                break;
            case 2:
                contextEnhance = new CashContextEnhance(new CashRebate(0.8));
                break;
            case 3:
                contextEnhance = new CashContextEnhance(new CashRebate(0.6));
                break;
            case 4:
                contextEnhance = new CashContextEnhance(new CashReturn(300d, 50d));
                break;
        }
    }

    public double getResult(double price, int num) {
        return this.cs.acceptCash(price, num);
    }

}
